<template>
  <div ref="echarts" style="width: 100%; height: 100%"></div>
</template>
  
  <script>
import * as echarts from "echarts";

export default {
  mounted() {
    this.initChart();
  },
  methods: {
    initChart() {
      const myChart = echarts.init(this.$refs.echarts);
      const option = {
        title: {
          text: "环境检测",
          left: 'center',
          top: '5%'
        },
        tooltip: {
          trigger: "axis",
          axisPointer: {
            type: "cross",
            label: {
              backgroundColor: "#6a7985",
            },
          },
        },
        legend: {
          data: ["温度", "湿度", "噪音"],
        },
        xAxis: [
          {
            type: "category",
            boundaryGap: false,
            data: ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"],
          },
        ],
        yAxis: [
          {
            type: "value",
          },
        ],
        series: [
          {
            name: "Temp",
            type: "line",
            stack: "Total",
            areaStyle: {},
            emphasis: {
              focus: "series",
            },
            data: [26.5, 22.5, 27.5, 26.5, 28.5, 31.5, 29.5],
          },
          {
            name: "RH",
            type: "line",
            stack: "Total",
            areaStyle: {},
            emphasis: {
              focus: "series",
            },
            data: [50, 62, 41, 73, 29, 33, 31],
          },
          {
            name: "db",
            type: "line",
            stack: "Total",
            areaStyle: {},
            emphasis: {
              focus: "series",
            },
            data: [15, 23, 20, 15, 19, 33, 41],
          },
        ]
      };
      myChart.setOption(option);
    },
  },
};
</script>
  